// Copyright 2019 The rhyme_lph Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// P [author] rhyme_lph
// K [email]  rhymelph@gmail.com
// M [github] https://github.com/rhymelph

import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/src/common/config.dart';
import 'package:finance_app/src/mixin/search_data_list_mixin.dart';
import 'package:finance_app/src/router_gen/router_gen_providers.dart';
import 'package:finance_app/src/utils/report_utils.dart';
import 'package:finance_app/src/widgets/bottom_sheet/delete_info_bottom_sheet.dart';
import 'package:finance_app/src/widgets/common/expandable.dart';

class ReportsProvider extends BaseProvider with SearchDataListMixin {
  ExpandableController saleExp = ExpandableController(initialExpanded: true);

  List<String> saleList = [
    'Sales By Period',
    'Sales By Customer',
    'Sales By Products / Services',
    'Aged Receivables Summary',
    'Aged Receivables Details',
  ];

  ExpandableController purchasesExp =
      ExpandableController(initialExpanded: true);
  List<String> purchasesList = [
    'Purchases By Period',
    'Purchases By Supplier',
    'Purchases By Products / Services',
    'Aged Payables Summary',
    'Aged Payables Details',
  ];

  ExpandableController inventoryExp =
      ExpandableController(initialExpanded: true);
  List<String> inventory = [
    'Inventory Valuation Summary',
    'Inventory Valuation Details',
  ];

  ExpandableController taxExp = ExpandableController(initialExpanded: true);
  List<String> taxes = [
    'GST F5',
    'GST Details',
    // 'Tax Computation',
  ];

  ExpandableController accountantsExp =
      ExpandableController(initialExpanded: true);
  List<String> accountants = [
    'Profit & Loss',
    'Balance Sheet',
    'Statement of Cash Flows',
    'General Ledger',
    'Journal Entries',
    'Bank Reconciliation',
    'Fixed Asset Listings',
  ];

  ExpandableController hrPayrollExp =
      ExpandableController(initialExpanded: true);
  List<String> hrPayrolls = [
    'Payroll Monthly Summary',
  ];

  @override
  Future get dataFuture => null;

  @override
  void searchRefreshData(data) {}

  void onNavDetail(String e) {
    if (ReportUtils.reportToType[e] == 76) {
      Routes.navigateTo(RouterGenProviders.bankReconciliationPage);
      return;
    }
    if (!Config.canAccessAdvanceFeature) {
      if (inventory.contains(e) ||
          taxes.contains(e) ||
          hrPayrolls.contains(e)) {
        obtainContext?.call((context) {
          showReadyForUpgradeBottomSheet(context);
        });
        return;
      }
    }
    Routes.navigateTo(RouterGenProviders.dateReportPage, params: {
      'type': ReportUtils.reportToType[e],
    });
  }
}
